package com.ttc.e9.paixu;

import java.util.Arrays;

public class Kuaisu {
	public static void quickSort(int[] arr, int low, int hign) {
		if (low < hign) {
			int i = low;
			int j = hign;
			while (i < j) {
				while (i < j && arr[i] <= arr[j]) {
					j--;
				}
				jiaohuan(arr, i, j);
				while (i < j && arr[i] <= arr[j]) {
					i++;
				}
				jiaohuan(arr, i, j);
			}
			quickSort(arr,low,j-1);
			quickSort(arr,j+1,hign);
		}
	}
	public static void jiaohuan(int[] arr, int i, int j) {
		int temp = arr[i];
		arr[i] = arr[j];
		arr[j] = temp;
	}
	public static void main(String[] args) {
		int[] arr={15,3,7,6,4,1,0,2,9,5,8};
		quickSort(arr,0,arr.length-1);
		System.out.println(Arrays.toString(arr));
	}
}
